<?php
/*
 * @class Acquisti_model
 * @author Francesco Benedet
 * @version 0.0.1
 * @created 2010-05-17
 * @modified 2010-05-17
 * @licence Da definire
 */

class Acquisti_model extends Model
{
  
  function getAcquisti()
  {
    $query = $this->db->get('Acquisti');
    return $query->result();
  }
  
  function getAcquistoById($idUtenti)
  {
    $query = $this->db->get_where('Acquisti', array('id_acquisti' => $idUtenti));
    return $query->result();
  }
  
  function getAcquistiByProduttore($idProduttori)
  {
    $query = $this->db->get_where('Acquisti', array('id_produttori' => $idProduttori));
    return $query->result();
  }
  
  function getAcquistiAperti()
  {
    $query = $this->db->get_where('Acquisti', array('dataora_chiusura >' => date('Y-m-d H:i:s')));
    return $query->result();
  }
  
  function getAcquistiChiusi()
  {
    $query = $this->db->get_where('Acquisti', array('dataora_chiusura <=' => date('Y-m-d H:i:s')));
    return $query->result();
  }
  
  function insertAcquisto($objAcquisto)
  {
    $query = $this->db->insert('Acquisti', $objAcquisto);
    return $query->result();
  }
  
  function updateAcquisto($objAcquisto)
  {
    $this->db->where(array('id_acquisti' => $objAcquisto['id_acquisti']));
    $query = $this->db->update('Acquisti', $objAcquisto);
    return $query->result();
  }
  
  function deleteAcquisto($idAcquisto)
  {
    $query = $this->db->delete('Acquisti', array('id_acquisti' => $idAcquisto));
    return $query->result();
  }
}

?>